package cn.iocoder.yudao.module.eval.controller.admin.subject.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.time.LocalDateTime;
import java.math.BigDecimal;

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

@Schema(description = "管理后台 - 评价科目新增/修改 Request VO")
@Data
public class EvalSubjectSaveReqVO {

    @Schema(description = "主键ID", example = "1024")
    private Long id;

    @Schema(description = "科目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "理论考试")
    @NotEmpty(message = "科目名称不能为空")
    @Size(max = 100, message = "科目名称长度不能超过100个字符")
    private String subjectName;

    @Schema(description = "科目代码", requiredMode = Schema.RequiredMode.REQUIRED, example = "THEORY-001")
    @NotEmpty(message = "科目代码不能为空")
    @Size(max = 50, message = "科目代码长度不能超过50个字符")
    private String subjectCode;

    @Schema(description = "计划ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotNull(message = "计划ID不能为空")
    private Long planId;

    @Schema(description = "科目类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "theory")
    @NotEmpty(message = "科目类型不能为空")
    @Pattern(regexp = "^(theory|practical|comprehensive)$", message = "科目类型必须是theory、practical、comprehensive之一")
    private String subjectType;

    @Schema(description = "考试方式", example = "written")
    @Pattern(regexp = "^(written|oral|computer|operation)$", message = "考试方式必须是written、oral、computer、operation之一")
    private String examMethod;

    @Schema(description = "满分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
    @NotNull(message = "满分不能为空")
    @DecimalMin(value = "0.01", message = "满分必须大于0")
    private BigDecimal maxScore;

    @Schema(description = "及格分", requiredMode = Schema.RequiredMode.REQUIRED, example = "60.00")
    @NotNull(message = "及格分不能为空")
    @DecimalMin(value = "0.01", message = "及格分必须大于0")
    private BigDecimal passScore;

    @Schema(description = "权重", example = "0.30")
    @DecimalMin(value = "0.01", message = "权重必须大于0")
    @DecimalMax(value = "1.00", message = "权重必须小于等于1")
    private BigDecimal weight;

    @Schema(description = "考试时长（分钟）", example = "120")
    @Min(value = 1, message = "考试时长必须大于0")
    private Integer duration;

    @Schema(description = "开始时间", example = "2024-01-01 09:00:00")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime startTime;

    @Schema(description = "结束时间", example = "2024-01-01 11:00:00")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime endTime;

    @Schema(description = "考试地点", example = "A栋301教室")
    @Size(max = 200, message = "考试地点长度不能超过200个字符")
    private String examLocation;

    @Schema(description = "科目说明", example = "本科目主要考查理论知识掌握情况")
    @Size(max = 1000, message = "科目说明长度不能超过1000个字符")
    private String subjectDescription;

    @Schema(description = "是否启用", example = "true")
    private Boolean enabled;

    // 服务实现兼容性方法
    public BigDecimal getSubjectWeight() {
        return weight;
    }

    public void setSubjectWeight(BigDecimal subjectWeight) {
        this.weight = subjectWeight;
    }

    public BigDecimal getPassingScore() {
        return passScore;
    }

    public void setPassingScore(BigDecimal passingScore) {
        this.passScore = passingScore;
    }

    public Integer getExamDuration() {
        return duration;
    }

    public void setExamDuration(Integer examDuration) {
        this.duration = examDuration;
    }

} 